import os
from PIL import Image

with open(r"C:\Users\12107\Desktop\test.txt","r") as file:
    lines = file.readlines()


lines = [line.strip() for line in lines]

for line in lines:
    line = line + '.JPG'
    image_path = os.path.join(r'E:\biaozhipai\JPEGImages',line)
    if os.path.isfile(image_path):
        image = Image.open(image_path)
        image.save(r'E:\biaozhipai\test_out\JPEGImages\\' + line)
    else:
        print("没有该图片")